package day05;
import java.util.Arrays;
/**
 * @author Huangjin
 * @version 1.0
 * describe:
 * @date 2023/2/16 15:58
 */
public class MaxOfArray {
    public static void main(String[] args) {
       //5)数组的排序
        int[] arr = new int[10];
        System.out.println("排序前：");
        for (int i = 0; i < arr.length; i++) {
            arr[i] = (int)(Math.random()*100);
            System.out.print(arr[i]+"\t");
        }
        System.out.println();
        System.out.println("排序后：");
        Arrays.sort(arr);
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]+"\t");
        }
        System.out.println();
        System.out.println("倒着输出：");
        for (int i = arr.length-1; i>=0; i--) {
            System.out.print(arr[i]+"\t");
        }
        /* int[] arr = new int[10];

        for (int i = 0; i < arr.length; i++) {
            arr[i] = (int)(Math.random()*100);
            System.out.print(arr[i]+"\t");
        }
        System.out.println();
        //找最大值：
        //假设第一个元素为最大值
        int max = arr[0];
        //遍历剩余元素
        for(int i =1;i<arr.length;i++){
            //剩余元素大于max
            if(arr[i]>max){
                //将max修改为较大的
                max = arr[i];
            }
        }
        System.out.print("最大值为："+max);*/
    }
}
